package com.dream.utils.log;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
/**
 * 
 * @author Evan
 * @date 2013/8/25
 *
 */
public class DreamLogUtils {
	
	private static final Log ERROR = SimpleLogFactory.getError();

	private static final Log DEBUG = SimpleLogFactory.getDebug();
	
	private static final Log APP =  SimpleLogFactory.getApp();

	private static final Log ACCESS = SimpleLogFactory.getAccess();
	
	private static final Log BUSINESS = SimpleLogFactory.getBusiness();
	
	public static void debug(Object c , String methodName ,String msg){
		
		if(DEBUG.isDebugEnabled() && c!=null && StringUtils.isNotBlank(msg)){
			
			StringBuilder sb = new StringBuilder("****** class:");
			sb.append(c.getClass().getName());
			sb.append("   method:");
			sb.append(methodName);
			sb.append("   message:");
			sb.append(msg);
			sb.append("  ******");
			DEBUG.debug(sb.toString());
			
		}
	}
	
	public static void error(Object c , String methodName ,String msg, Exception e){
		
		if(ERROR.isErrorEnabled() &&  c!=null){
			
			StringBuilder sb = new StringBuilder("****** class:");
			sb.append(c.getClass().getName());
			sb.append("   method:");
			sb.append(methodName);
			sb.append("   message:");
			sb.append(msg);
			sb.append("  has some exception ******");
			ERROR.error(sb.toString(), e);
			
		}
	}
	
	public static void appInfo(Object c , String methodName ,String msg){
		
		if(APP.isInfoEnabled()  && c!=null && StringUtils.isNotBlank(msg)){
			
			StringBuilder sb = new StringBuilder("****** class:");
			sb.append(c.getClass().getName());
			sb.append("   method:");
			sb.append(methodName);
			sb.append("   message:");
			sb.append(msg);
			sb.append("  ******");
			APP.info(sb.toString());
			
		}
	}
	
	public static void accessInfo(String msg){
		
		if(ACCESS.isInfoEnabled() && StringUtils.isNotBlank(msg)){
			
			ACCESS.info(msg);
			
		}
	}
	
	public static void businessInfo(Object c , String methodName ,String msg){
		
		if(BUSINESS.isInfoEnabled()  && c!=null && StringUtils.isNotBlank(msg)){
			
			StringBuilder sb = new StringBuilder("****** class:");
			sb.append(c.getClass().getName());
			sb.append("   method:");
			sb.append(methodName);
			sb.append("   message:");
			sb.append(msg);
			sb.append("  ******");
			BUSINESS.info(sb.toString());
			
		}
	}
}
